<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Redis," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis hash 是一个string类型的field和value的映射表，hash特别适合用于存储对象。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis 中每个 hash 可以存储 232 - 1 键值对（40多亿）。 实例12345678">
<meta name="keywords" content="Redis">
<meta property="og:type" content="article">
<meta property="og:title" content="Redis 哈希(Hash)">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/Redis/19. Redis 哈希(Hash)/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis hash 是一个string类型的field和value的映射表，hash特别适合用于存储对象。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis 中每个 hash 可以存储 232 - 1 键值对（40多亿）。 实例12345678">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-02T17:32:07.619Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Redis 哈希(Hash)">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis hash 是一个string类型的field和value的映射表，hash特别适合用于存储对象。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis 中每个 hash 可以存储 232 - 1 键值对（40多亿）。 实例12345678">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/Redis/19. Redis 哈希(Hash)/"/>





  <title>Redis 哈希(Hash) | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/Redis/19. Redis 哈希(Hash)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Redis 哈希(Hash)</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T02:09:22+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis hash 是一个string类型的field和value的映射表，hash特别适合用于存储对象。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis 中每个 hash 可以存储 232 - 1 键值对（40多亿）。</p>
<h2 id="实例"><a href="#实例" class="headerlink" title="实例"></a>实例</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">127.0.0.1:6379&gt; HMSET runoobkey name <span class="string">"redis tutorial"</span> description <span class="string">"redis basic commands for caching"</span> likes 20 visitors 23000</div><div class="line">OK</div><div class="line">127.0.0.1:6379&gt; HGETALL runoobkey</div><div class="line">1) <span class="string">"name"</span></div><div class="line">2) <span class="string">"redis tutorial"</span></div><div class="line">3) <span class="string">"description"</span></div><div class="line">4) <span class="string">"redis basic commands for caching"</span></div><div class="line">5) <span class="string">"likes"</span></div><div class="line">6) <span class="string">"20"</span></div><div class="line">7) <span class="string">"visitors"</span></div><div class="line">8) <span class="string">"23000"</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在以上实例中，我们设置了 redis 的一些描述信息(name, description, likes, visitors) 到哈希表的 <strong>runoobkey</strong> 中。</p>
<h2 id="Redis-hash-命令"><a href="#Redis-hash-命令" class="headerlink" title="Redis hash 命令"></a>Redis hash 命令</h2><h3 id="1-Redis-Hdel-命令"><a href="#1-Redis-Hdel-命令" class="headerlink" title="1.Redis Hdel 命令"></a>1.Redis Hdel 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HDEL key field2 [field2]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>删除一个或多个哈希表字段</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hdel 命令用于删除哈希表 key 中的一个或多个指定字段，不存在的字段将被忽略。</p>
<h4 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hdel 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HDEL KEY_NAME FIELD1.. FIELDN</div></pre></td></tr></table></figure>
<h4 id="可用版本"><a href="#可用版本" class="headerlink" title="可用版本"></a>可用版本</h4><h4 id="返回值"><a href="#返回值" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;被成功删除字段的数量，不包括被忽略的字段。</p>
<h4 id="实例-1"><a href="#实例-1" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HDEL myhash field1</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HDEL myhash field2</div><div class="line">(<span class="built_in">integer</span>) 0</div></pre></td></tr></table></figure>
<h3 id="2-Redis-Hexists-命令"><a href="#2-Redis-Hexists-命令" class="headerlink" title="2.Redis Hexists 命令"></a>2.Redis Hexists 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HEXISTS key field</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<figure class="highlight plain"><figcaption><span>key 中，指定的字段是否存在```</span></figcaption><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis Hexists 命令用于查看哈希表的指定字段是否存在。</div><div class="line"></div><div class="line">#### 语法</div><div class="line">&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;redis Hexists 命令基本语法如下：</div><div class="line"></div><div class="line">```bash</div><div class="line">redis 127.0.0.1:6379&gt; HEXISTS KEY_NAME FIELD_NAME</div></pre></td></tr></table></figure></p>
<h4 id="可用版本-1"><a href="#可用版本-1" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-1"><a href="#返回值-1" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果哈希表含有给定字段，返回 1 。 如果哈希表不含有给定字段，或 key 不存在，返回 0 。</p>
<h4 id="实例-2"><a href="#实例-2" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HEXISTS myhash field1</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HEXISTS myhash field2</div><div class="line">(<span class="built_in">integer</span>) 0</div></pre></td></tr></table></figure>
<h3 id="3-Redis-Hget-命令"><a href="#3-Redis-Hget-命令" class="headerlink" title="3.Redis Hget 命令"></a>3.Redis Hget 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HGET key field</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>获取存储在哈希表中指定字段的值</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hget 命令用于返回哈希表中指定字段的值。</p>
<h4 id="语法-1"><a href="#语法-1" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hget 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HGET KEY_NAME FIELD_NAME</div></pre></td></tr></table></figure>
<h4 id="可用版本-2"><a href="#可用版本-2" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-2"><a href="#返回值-2" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;返回给定字段的值。如果给定的字段或 key 不存在时，返回 nil 。</p>
<h4 id="实例-3"><a href="#实例-3" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># 字段存在</span></div><div class="line"> </div><div class="line">redis&gt; HSET site redis redis.com</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line"> </div><div class="line">redis&gt; HGET site redis</div><div class="line"><span class="string">"redis.com"</span></div><div class="line"> </div><div class="line"> </div><div class="line"><span class="comment"># 字段不存在</span></div><div class="line"> </div><div class="line">redis&gt; HGET site mysql</div><div class="line">(nil)</div></pre></td></tr></table></figure>
<h3 id="4-Redis-Hgetall-命令"><a href="#4-Redis-Hgetall-命令" class="headerlink" title="4..Redis Hgetall 命令"></a>4..Redis Hgetall 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HGETALL key</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>获取在哈希表中指定 key 的所有字段和值</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hgetall 命令用于返回哈希表中，所有的字段和值。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在返回值里，紧跟每个字段名(field name)之后是字段的值(value)，所以返回值的长度是哈希表大小的两倍。</p>
<h4 id="语法-2"><a href="#语法-2" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hgetall 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HGETALL KEY_NAME</div></pre></td></tr></table></figure>
<h4 id="可用版本-3"><a href="#可用版本-3" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-3"><a href="#返回值-3" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;以列表形式返回哈希表的字段及字段值。 若 key 不存在，返回空列表。</p>
<h4 id="实例-4"><a href="#实例-4" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field2 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HGETALL myhash</div><div class="line">1) <span class="string">"field1"</span></div><div class="line">2) <span class="string">"Hello"</span></div><div class="line">3) <span class="string">"field2"</span></div><div class="line">4) <span class="string">"World"</span></div></pre></td></tr></table></figure>
<h3 id="5-Redis-Hincrby-命令"><a href="#5-Redis-Hincrby-命令" class="headerlink" title="5.Redis Hincrby 命令"></a>5.Redis Hincrby 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HINCRBY key field increment</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>为哈希表 key 中的指定字段的整数值加上增量 increment</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hincrby 命令用于为哈希表中的字段值加上指定增量值。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;增量也可以为负数，相当于对指定字段进行减法操作。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果哈希表的 key 不存在，一个新的哈希表被创建并执行 HINCRBY 命令。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果指定的字段不存在，那么在执行命令前，字段的值被初始化为 0 。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;对一个储存字符串值的字段执行 HINCRBY 命令将造成一个错误。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;本操作的值被限制在 64 位(bit)有符号数字表示之内。</p>
<h4 id="语法-3"><a href="#语法-3" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hincrby 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HINCRBY KEY_NAME FIELD_NAME INCR_BY_NUMBER</div></pre></td></tr></table></figure>
<h4 id="可用版本-4"><a href="#可用版本-4" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-4"><a href="#返回值-4" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;执行 HINCRBY 命令之后，哈希表中字段的值。</p>
<h4 id="实例-5"><a href="#实例-5" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">redis&gt; HSET myhash field 5</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis&gt; HINCRBY myhash field 1</div><div class="line">(<span class="built_in">integer</span>) 6</div><div class="line">redis&gt; HINCRBY myhash field -1</div><div class="line">(<span class="built_in">integer</span>) 5</div><div class="line">redis&gt; HINCRBY myhash field -10</div><div class="line">(<span class="built_in">integer</span>) -5</div><div class="line">redis&gt;</div></pre></td></tr></table></figure>
<h3 id="6-Redis-Hincrbyfloat-命令"><a href="#6-Redis-Hincrbyfloat-命令" class="headerlink" title="6.Redis Hincrbyfloat 命令"></a>6.Redis Hincrbyfloat 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HINCRBYFLOAT key field increment</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>为哈希表 key 中的指定字段的浮点数值加上增量 increment</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hincrbyfloat 命令用于为哈希表中的字段值加上指定浮点数增量值。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果指定的字段不存在，那么在执行命令前，字段的值被初始化为 0 。</p>
<h4 id="语法-4"><a href="#语法-4" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hincrbyfloat 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HINCRBYFLOAT KEY_NAME FIELD_NAME INCR_BY_NUMBER</div></pre></td></tr></table></figure>
<h4 id="可用版本-5"><a href="#可用版本-5" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.6.0</p>
<h4 id="返回值-5"><a href="#返回值-5" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;执行 Hincrbyfloat 命令之后，哈希表中字段的值。</p>
<h4 id="实例-6"><a href="#实例-6" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">redis&gt; HSET mykey field 10.50</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis&gt; HINCRBYFLOAT mykey field 0.1</div><div class="line"><span class="string">"10.60000000000000001"</span></div><div class="line">redis&gt; HINCRBYFLOAT mykey field -5</div><div class="line"><span class="string">"5.59999999999999964"</span></div><div class="line">redis&gt; HSET mykey field 5.0e3</div><div class="line">(<span class="built_in">integer</span>) 0</div><div class="line">redis&gt; HINCRBYFLOAT mykey field 2.0e2</div><div class="line"><span class="string">"5200"</span></div><div class="line">redis&gt;</div></pre></td></tr></table></figure>
<h3 id="7-Redis-Hkeys-命令"><a href="#7-Redis-Hkeys-命令" class="headerlink" title="7.Redis Hkeys 命令"></a>7.Redis Hkeys 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HKEYS key</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>获取所有哈希表中的字段</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hkeys 命令用于获取哈希表中的所有字段名。</p>
<h4 id="语法-5"><a href="#语法-5" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hkeys 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HKEYS KEY_NAME FIELD_NAME INCR_BY_NUMBER</div></pre></td></tr></table></figure>
<h4 id="可用版本-6"><a href="#可用版本-6" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-6"><a href="#返回值-6" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;包含哈希表中所有字段的列表。 当 key 不存在时，返回一个空列表。</p>
<h4 id="实例-7"><a href="#实例-7" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field2 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HKEYS myhash</div><div class="line">1) <span class="string">"field1"</span></div><div class="line">2) <span class="string">"field2"</span></div></pre></td></tr></table></figure>
<h3 id="8-Redis-Hlen-命令"><a href="#8-Redis-Hlen-命令" class="headerlink" title="8.Redis Hlen 命令"></a>8.Redis Hlen 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HLEN key</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>获取哈希表中字段的数量</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hlen 命令用于获取哈希表中字段的数量。</p>
<h4 id="语法-6"><a href="#语法-6" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hlen 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HLEN KEY_NAME</div></pre></td></tr></table></figure>
<h4 id="可用版本-7"><a href="#可用版本-7" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-7"><a href="#返回值-7" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;哈希表中字段的数量。 当 key 不存在时，返回 0 。</p>
<h4 id="实例-8"><a href="#实例-8" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field2 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HLEN myhash</div><div class="line">(<span class="built_in">integer</span>) 2</div></pre></td></tr></table></figure>
<h3 id="9-Redis-Hmget-命令"><a href="#9-Redis-Hmget-命令" class="headerlink" title="9.Redis Hmget 命令"></a>9.Redis Hmget 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HMGET key field1 [field2]</code><br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>获取所有给定字段的值</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hmget 命令用于返回哈希表中，一个或多个给定字段的值。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果指定的字段不存在于哈希表，那么返回一个 nil 值。</p>
<h4 id="语法-7"><a href="#语法-7" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hmget 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HMGET KEY_NAME FIELD1...FIELDN</div></pre></td></tr></table></figure>
<h4 id="可用版本-8"><a href="#可用版本-8" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-8"><a href="#返回值-8" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;一个包含多个给定字段关联值的表，表值的排列顺序和指定字段的请求顺序一样。</p>
<h4 id="实例-9"><a href="#实例-9" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field2 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HMGET myhash field1 field2 nofield</div><div class="line">1) <span class="string">"foo"</span></div><div class="line">2) <span class="string">"bar"</span></div><div class="line">3) (nil)</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HMSET key field1 value1 [field2 value2 ]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>同时将多个 field-value (域-值)对设置到哈希表 key 中</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hmset 命令用于同时将多个 field-value (字段-值)对设置到哈希表中。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;此命令会覆盖哈希表中已存在的字段。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果哈希表不存在，会创建一个空哈希表，并执行 HMSET 操作。</p>
<h4 id="语法-8"><a href="#语法-8" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hmset 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HMSET KEY_NAME FIELD1 VALUE1 ...FIELDN VALUEN</div></pre></td></tr></table></figure>
<h4 id="可用版本-9"><a href="#可用版本-9" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-9"><a href="#返回值-9" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果命令执行成功，返回 OK 。</p>
<h4 id="实例-10"><a href="#实例-10" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HMSET myhash field1 <span class="string">"Hello"</span> field2 <span class="string">"World"</span></div><div class="line">OK</div><div class="line">redis 127.0.0.1:6379&gt; HGET myhash field1</div><div class="line"><span class="string">"Hello"</span></div><div class="line">redis 127.0.0.1:6379&gt; HGET myhash field2</div><div class="line"><span class="string">"World"</span></div></pre></td></tr></table></figure>
<h3 id="11-Redis-Hset-命令"><a href="#11-Redis-Hset-命令" class="headerlink" title="11.Redis Hset 命令"></a>11.Redis Hset 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HSET key field value</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>将哈希表 key 中的字段 field 的值设为 value</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hset 命令用于为哈希表中的字段赋值 。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果哈希表不存在，一个新的哈希表被创建并进行 HSET 操作。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果字段已经存在于哈希表中，旧值将被覆盖。</p>
<h4 id="语法-9"><a href="#语法-9" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hset 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET KEY_NAME FIELD VALUE</div></pre></td></tr></table></figure>
<h4 id="可用版本-10"><a href="#可用版本-10" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-10"><a href="#返回值-10" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果字段是哈希表中的一个新建字段，并且值设置成功，返回 1 。 如果哈希表中域字段已经存在且旧值已被新值覆盖，返回 0 。</p>
<h4 id="实例-11"><a href="#实例-11" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field1 <span class="string">"foo"</span></div><div class="line">OK</div><div class="line">redis 127.0.0.1:6379&gt; HGET myhash field1</div><div class="line"><span class="string">"foo"</span></div><div class="line"> </div><div class="line">redis 127.0.0.1:6379&gt; HSET website google <span class="string">"www.g.cn"</span> <span class="comment"># 设置一个新域</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line"> </div><div class="line">redis 127.0.0.1:6379&gt;HSET website google <span class="string">"www.google.com"</span> <span class="comment"># 覆盖一个旧域</span></div><div class="line">(<span class="built_in">integer</span>) 0</div></pre></td></tr></table></figure>
<h3 id="12-Redis-Hsetnx-命令"><a href="#12-Redis-Hsetnx-命令" class="headerlink" title="12.Redis Hsetnx 命令"></a>12.Redis Hsetnx 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HSETNX key field value</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>只有在字段 field 不存在时，设置哈希表字段的值</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hsetnx 命令用于为哈希表中不存在的的字段赋值 。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果哈希表不存在，一个新的哈希表被创建并进行 HSET 操作。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果字段已经存在于哈希表中，操作无效。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果 key 不存在，一个新哈希表被创建并执行 HSETNX 命令。</p>
<h4 id="语法-10"><a href="#语法-10" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hsetnx 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSETNX KEY_NAME FIELD VALUE</div></pre></td></tr></table></figure>
<h4 id="可用版本-11"><a href="#可用版本-11" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-11"><a href="#返回值-11" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;设置成功，返回 1 。 如果给定字段已经存在且没有操作被执行，返回 0 。</p>
<h4 id="实例-12"><a href="#实例-12" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSETNX myhash field1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HSETNX myhash field1 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 0</div><div class="line">redis 127.0.0.1:6379&gt; HGET myhash field1</div><div class="line"><span class="string">"foo"</span></div><div class="line"> </div><div class="line">redis 127.0.0.1:6379&gt; HSETNX nosql key-value-store redis</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line"> </div><div class="line">redis 127.0.0.1:6379&gt; HSETNX nosql key-value-store redis <span class="comment"># 操作无效， key-value-store 已存在</span></div><div class="line">(<span class="built_in">integer</span>) 0</div></pre></td></tr></table></figure>
<h3 id="13-Redis-Hvals-命令"><a href="#13-Redis-Hvals-命令" class="headerlink" title="13.Redis Hvals 命令"></a>13.Redis Hvals 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>HVALS key</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>获取哈希表中所有值</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Hvals 命令返回哈希表所有字段的值。</p>
<h4 id="语法-11"><a href="#语法-11" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Hvals 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HVALS KEY_NAME FIELD VALUE</div></pre></td></tr></table></figure>
<h4 id="可用版本-12"><a href="#可用版本-12" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 2.0.0</p>
<h4 id="返回值-12"><a href="#返回值-12" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;一个包含哈希表中所有值的表。 当 key 不存在时，返回一个空表。</p>
<h4 id="实例-13"><a href="#实例-13" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HSET myhash field2 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; HVALS myhash</div><div class="line">1) <span class="string">"foo"</span></div><div class="line">2) <span class="string">"bar"</span></div><div class="line"> </div><div class="line"><span class="comment"># 空哈希表/不存在的key</span></div><div class="line"> </div><div class="line">redis 127.0.0.1:6379&gt; EXISTS not_exists</div><div class="line">(<span class="built_in">integer</span>) 0</div><div class="line"> </div><div class="line">redis 127.0.0.1:6379&gt; HVALS not_exists</div><div class="line">(empty list or <span class="built_in">set</span>)</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Redis/" rel="tag"># Redis</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/Redis/17. Redis 命令/" rel="next" title="Redis 命令">
                <i class="fa fa-chevron-left"></i> Redis 命令
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/Redis/20. Redis 列表(List)/" rel="prev" title="Redis 列表(List)">
                Redis 列表(List) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#实例"><span class="nav-number">1.</span> <span class="nav-text">实例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Redis-hash-命令"><span class="nav-number">2.</span> <span class="nav-text">Redis hash 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-Redis-Hdel-命令"><span class="nav-number">2.1.</span> <span class="nav-text">1.Redis Hdel 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法"><span class="nav-number">2.1.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本"><span class="nav-number">2.1.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值"><span class="nav-number">2.1.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-1"><span class="nav-number">2.1.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-Redis-Hexists-命令"><span class="nav-number">2.2.</span> <span class="nav-text">2.Redis Hexists 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-1"><span class="nav-number">2.2.1.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-1"><span class="nav-number">2.2.2.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-2"><span class="nav-number">2.2.3.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-Redis-Hget-命令"><span class="nav-number">2.3.</span> <span class="nav-text">3.Redis Hget 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-1"><span class="nav-number">2.3.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-2"><span class="nav-number">2.3.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-2"><span class="nav-number">2.3.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-3"><span class="nav-number">2.3.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-Redis-Hgetall-命令"><span class="nav-number">2.4.</span> <span class="nav-text">4..Redis Hgetall 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-2"><span class="nav-number">2.4.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-3"><span class="nav-number">2.4.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-3"><span class="nav-number">2.4.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-4"><span class="nav-number">2.4.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-Redis-Hincrby-命令"><span class="nav-number">2.5.</span> <span class="nav-text">5.Redis Hincrby 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-3"><span class="nav-number">2.5.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-4"><span class="nav-number">2.5.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-4"><span class="nav-number">2.5.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-5"><span class="nav-number">2.5.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-Redis-Hincrbyfloat-命令"><span class="nav-number">2.6.</span> <span class="nav-text">6.Redis Hincrbyfloat 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-4"><span class="nav-number">2.6.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-5"><span class="nav-number">2.6.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-5"><span class="nav-number">2.6.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-6"><span class="nav-number">2.6.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-Redis-Hkeys-命令"><span class="nav-number">2.7.</span> <span class="nav-text">7.Redis Hkeys 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-5"><span class="nav-number">2.7.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-6"><span class="nav-number">2.7.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-6"><span class="nav-number">2.7.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-7"><span class="nav-number">2.7.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#8-Redis-Hlen-命令"><span class="nav-number">2.8.</span> <span class="nav-text">8.Redis Hlen 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-6"><span class="nav-number">2.8.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-7"><span class="nav-number">2.8.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-7"><span class="nav-number">2.8.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-8"><span class="nav-number">2.8.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#9-Redis-Hmget-命令"><span class="nav-number">2.9.</span> <span class="nav-text">9.Redis Hmget 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-7"><span class="nav-number">2.9.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-8"><span class="nav-number">2.9.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-8"><span class="nav-number">2.9.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-9"><span class="nav-number">2.9.4.</span> <span class="nav-text">实例</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-8"><span class="nav-number">2.9.5.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-9"><span class="nav-number">2.9.6.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-9"><span class="nav-number">2.9.7.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-10"><span class="nav-number">2.9.8.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#11-Redis-Hset-命令"><span class="nav-number">2.10.</span> <span class="nav-text">11.Redis Hset 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-9"><span class="nav-number">2.10.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-10"><span class="nav-number">2.10.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-10"><span class="nav-number">2.10.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-11"><span class="nav-number">2.10.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#12-Redis-Hsetnx-命令"><span class="nav-number">2.11.</span> <span class="nav-text">12.Redis Hsetnx 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-10"><span class="nav-number">2.11.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-11"><span class="nav-number">2.11.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-11"><span class="nav-number">2.11.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-12"><span class="nav-number">2.11.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#13-Redis-Hvals-命令"><span class="nav-number">2.12.</span> <span class="nav-text">13.Redis Hvals 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-11"><span class="nav-number">2.12.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-12"><span class="nav-number">2.12.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-12"><span class="nav-number">2.12.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-13"><span class="nav-number">2.12.4.</span> <span class="nav-text">实例</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
